package com.tencent.trtc.apiexample;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Looper;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.tencent.trtc.apiexample.ui.notifications.NotificationsFragment;

import static com.tencent.trtc.apiexample.LoginActivity.PATH;
import static com.tencent.trtc.apiexample.LoginActivity.USERNAME;

public class AlterPwdActivity extends AppCompatActivity {
    private EditText met_old_pwd;
    private EditText met_new_pwd;
    private Button mbtn_pwd_confirm;
    private String password_old = "";
    private String password_new = "";
    private String path = "";
    private String result = "";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_alter_pwd);

        met_old_pwd=findViewById(R.id.et_old_pwd);
        met_new_pwd=findViewById(R.id.et_new_pwd);
        mbtn_pwd_confirm=findViewById(R.id.btn_pwd_confirm);

        mbtn_pwd_confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new MyThread()).start();
            }
        });
    }
    class MyThread implements Runnable {

        @Override
        public void run() {
            password_old = met_old_pwd.getText().toString();
            password_new = met_new_pwd.getText().toString();
            path = PATH + "/updatepwd?username="+USERNAME+"&password_old="+password_old+"&password_new="+password_new;
            result = WebServiceGet.executeHttpGet(path);
            Intent intent = new Intent(AlterPwdActivity.this, NavActivity.class);
            intent.putExtra("result",result);
            startActivity(intent);
        }
    }
}